package com.leyou.config;

import com.leyou.interceptor.PassportInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Component
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    PassportInterceptor passportInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> excludePatterns = new ArrayList<String>();
        excludePatterns.add("/login.html");
        excludePatterns.add("/reg.html");
        excludePatterns.add("/find.html");
        registry.addInterceptor(passportInterceptor).addPathPatterns("/**.html").excludePathPatterns(excludePatterns);
    }
}
